*****.Do File for Appendix C*****

*Set Working Directory

cd "C:\Users\gundejac\Dropbox\Dissertation\Paper 1\Mapping ISD"

***Creat Log file***

log using "TCSC_Robustness_Checks.log", replace

****Country-Election level results*****

*Open data set*

use "Data\election.dta"

*set data as time-series cross-sectional

tsset ccode time

*Make dummy variables that work in stata*

encode region, generate(west) 

encode exec, generate(executive)

encode type, generate(electoral)

encode period, generate(time_period)

encode(countryname), generate(name)

*run prais-winsten regression with period dummies
eststo clear

eststo: prais diff_scale age_10 enep_scale econ_pol_scale nonecon_pol_scale  gal_dis_scale 

eststo: prais diff_scale age_10 enep_scale econ_pol_scale nonecon_pol_scale  gal_dis_scale i.time_period

eststo: prais diff_scale age_10 enep_scale econ_pol_scale nonecon_pol_scale  gal_dis_scale i.ccode

eststo: prais diff_scale age_10 enep_scale econ_pol_scale nonecon_pol_scale  gal_dis_scale i.time_period i.ccode

esttab, se n r2 ar2  star(+ 0.10 * 0.05 ** 0.01 *** 0.001) title(Table 4) keep(age_10 enep_scale econ_pol_scale nonecon_pol_scale gal_dis_scale) nonumbers mtitles("Model 1" "Model 2" "Model 3" "Model 4")

*Close data*

clear

*****Party-Election level results****

*Open data set*

use "Data\party_level.dta"

*set data as time-series cross-sectional*

tsset party time

**Make dummy variables that work in stata*

encode region, generate(west) 

gen West = 1
replace West = 0 if region=="East"

encode exec, generate(executive)

encode type, generate(electoral)

encode period, generate(time_period)

encode Mainstream, generate(main_family)

gen Main = 1
replace Main = 0 if Mainstream=="Challenger"


*run prais-winsten regression with with period dummies (All cases)

eststo clear

eststo:  prais sal_dif year_10 age age2 age3 pervote_lag Main econ_pol nonecon_pol enep i.executive i.electoral

eststo:  prais sal_dif year_10 age age2 age3 pervote_lag Main econ_pol nonecon_pol enep i.executive i.electoral i.time_period

eststo:  prais sal_dif year_10 age age2 age3 pervote_lag Main econ_pol nonecon_pol enep i.executive i.electoral if West == 1

eststo:  prais sal_dif year_10 age age2 age3 pervote_lag Main econ_pol nonecon_pol enep i.executive i.electoral i.time_period if West == 1

eststo:  prais sal_dif year_10 age age2 age3 pervote_lag Main econ_pol nonecon_pol enep i.executive i.electoral if West == 0

eststo:  prais sal_dif year_10 age age2 age3 pervote_lag Main econ_pol nonecon_pol enep i.executive i.electoral i.time_period if West == 0

esttab,  se n r2 ar2  star(+ 0.10 * 0.05 ** 0.01 *** 0.001) title(Table 6) keep(year_10 age age2 age3 pervote_lag Main econ_pol nonecon_pol enep *.executive *.electoral) nonumbers mtitles("Model 1" "Model 2" "Model 3" "Model 4" "Model 5" "Model 6")


*Close the log file*

log close
